package zhouzhouyongche.action;

import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import zhouzhouyongche.client_util.Json;
import zhouzhouyongche.service.PassengerStationService;

@Controller
@Action(value="passengerStation")
public class PassengerStationAction extends BaseAction {

	@Autowired
	private PassengerStationService passengerStationService;
	
	private int cityId;
	private String passengerStationName;
	
	public void getPassengerStation() {
		List list = passengerStationService.getPassengerStation(cityId);
		writeJson(list);
	}
	
	public void getAllPassengerStations() {
		List list = passengerStationService.getAllPassengerStation();
		writeJson(list.size(), list);
	}
	
	public void addPassengerStation() {
		Json json = new Json();
		try {
			passengerStationService.addPassengerStation(cityId, passengerStationName);
			json.setSuccess(true);
			json.setMsg("添加汽车站成功");
		} catch (Exception e) {
			e.printStackTrace();
			json.setSuccess(false);
			json.setMsg("添加汽车站失败");
		}
		writeJson(json);
	}

	public int getCityId() {
		return cityId;
	}

	public void setCityId(int cityId) {
		this.cityId = cityId;
	}

	public String getPassengerStationName() {
		return passengerStationName;
	}

	public void setPassengerStationName(String passengerStationName) {
		this.passengerStationName = passengerStationName;
	}
}
